package com.huaqiang.test.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaqiang.test.pojo.vo.AlertHandleVo;
import com.huaqiang.test.pojo.query.AlertHandleQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.huaqiang.test.pojo.entity.AlertHandle;
import com.huaqiang.test.mapper.AlertHandleMapper;
import com.huaqiang.test.service.AlertHandleService;

import java.util.List;
/**
 * 告警处理表 服务实现类
 *
 * @author crelle
 * @since 2025-03-20 04:48:55
 */
@Service
public class AlertHandleServiceImpl extends ServiceImpl<AlertHandleMapper, AlertHandle> implements AlertHandleService {

    @Autowired
    private AlertHandleMapper alerthandleMapper;

    /**
     * 增加AlertHandle
     *
     * @param alerthandle
     * @return
     */
    @Override
    public AlertHandle create(AlertHandle alerthandle) {
        super.save(alerthandle);
        return alerthandle;
    }

    /**
     * 批量增加AlertHandle
     *
     * @param alerthandles
     * @return
     */
    @Override
    public List<AlertHandle> create(List<AlertHandle> alerthandles) {
        super.saveBatch(alerthandles);
        return alerthandles;
    }

    /**
     * 根据id删除AlertHandle
     *
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(String id) {
        return super.removeById(id);
    }

    /**
     * 根据id批量删除AlertHandle
     *
     * @param ids
     * @return
     */
    @Override
    public boolean deleteByIds(List<String> ids) {
        return super.removeBatchByIds(ids);
    }

    /**
     * 根据id修改AlertHandle
     *
     * @param alerthandle
     * @return
     */
    @Override
    public boolean update(AlertHandle alerthandle) {
        return super.updateById(alerthandle);
    }

    /**
     * 根据id批量修改AlertHandle
     *
     * @param alerthandles
     * @return
     */
    @Override
    public boolean updates(List<AlertHandle> alerthandles) {
        return super.updateBatchById(alerthandles);
    }

    /**
     * 自动分页查询AlertHandle，仅仅适用于单表查询
     *
     * @param page
     * @return
     */
    @Override
    public Page<AlertHandle> pageByCondition(Page<AlertHandle> page) {
        LambdaQueryWrapper<AlertHandle> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (null != page && page.getRecords().size() != 0) {
            AlertHandle alerthandle = page.getRecords().get(0);
            lambdaQueryWrapper.like(null != alerthandle.getId(), AlertHandle::getId, alerthandle.getId());
        }
        return super.page(page, lambdaQueryWrapper);
    }

    /**
     * 手动分页查询AlertHandle，用于多表查询
     *
     * @param pageBean
     * @return
     */
    @Override
    public Page<AlertHandleVo> manualPage(Page<AlertHandleQuery> pageBean) {
        return null;
    }

    /**
     * 查询AlertHandle详情
     *
     * @param id
     * @return
     */
    @Override
    public AlertHandle queryById(String id) {
        return super.getById(id);
    }

    /**
     * 根据id批量查询AlertHandle
     *
     * @param ids
     * @return
     */
    @Override
    public List<AlertHandle> queryByIds(List<String> ids) {
        return super.listByIds(ids);
    }

    /**
     * 查询所有AlertHandle
     *
     * @return
     */
    @Override
    public List<AlertHandle> queryAll() {
        return super.list();
    }
}
